import {Module} from 'vuex';
// 此处加上 `.ts` 后缀报错，具体原因不详
import {ThemeConfigState, RootStateTypes} from '/@/store/interface/index';

/**
 * 2020.05.28 by lyt 优化
 * 修改一下配置时，需要每次都清理 `window.localStorage` 浏览器永久缓存，配置才会生效
 * 哪个大佬有解决办法，欢迎pr，感谢💕！
 */
const themeConfigModule: Module<ThemeConfigState, RootStateTypes> = {
    namespaced: true,
    state: {

        themeConfig: {
            "isDrawer": false,
            "primary": "#409eff",
            "success": "#67c23a",
            "info": "#909399",
            "warning": "#e6a23c",
            "danger": "#f56c6c",
            "topBar": "#ffffff",
            "menuFontBackgroundHeightLight": "#ffffff", //菜单栏字体背景高亮
            "menuBar": "#182736",//菜单栏底色
            "columnsMenuBar": "#545c64",
            "topBarColor": "#0B0B0B",
            "menuBarColor": "#FFFFFF",
            "columnsMenuBarColor": "#3786d8",
            "isTopBarColorGradual": false,
            "isMenuBarColorGradual": false,
            "isColumnsMenuBarColorGradual": false,
            "isMenuBarColorHighlight": true,
            "isCollapse": false,
            "isUniqueOpened": false,
            "isFixedHeader": false,
            "isFixedHeaderChange": false,
            "isClassicSplitMenu": false,
            "isLockScreen": false,
            "lockScreenTime": 30,
            "isShowLogo": true,
            "isShowLogoChange": false,
            "isBreadcrumb": true,
            "isTagsview": true,
            "isBreadcrumbIcon": false,
            "isTagsviewIcon": false,
            "isCacheTagsView": false,
            "isSortableTagsView": true,
            "isShareTagsView": false,
            "isFooter": false,
            "isGrayscale": false,
            "isInvert": false,
            "isIsDark": false,
            "isCool": false,
            "isWartermark": false,
            "wartermarkText": "山河湾谷创新区",
            "tagsStyle": "tags-style-one",
            "animation": "slide-right",
            "columnsAsideStyle": "columns-round",
            "columnsAsideLayout": "columns-vertical",
            "layout": "defaults",
            "isRequestRoutes": false,
            "globalTitle": "山河湾谷创新区",  //菜单栏左上角标题
            "globalViceTitle": "山河湾谷创新区",
            "globalI18n": "zh-cn",
            "globalComponentSize": "small"
        }
    },
    mutations: {
        // 设置布局配置
        getThemeConfig(state: any, data: object) {
            state.themeConfig = data;
        },
        setIsRequestRoutes(state: any, isRequestRoutes: boolean) {

            state.themeConfig.isRequestRoutes = isRequestRoutes
        },
        getIsRequestRoutes(state: any) {
            return state.themeConfig.isRequestRoutes;
        }
    },
    actions: {
        // 设置布局配置
        setThemeConfig({commit}, data: object) {
            commit('getThemeConfig', data);
        },
        setIsRequestRoutes({commit}, isRequestRoutes: boolean) {
            commit('setIsRequestRoutes', isRequestRoutes);
        },
        getIsRequestRoutes({commit}) {
            commit('getIsRequestRoutes');
        },

    },
};

export default themeConfigModule;
